;2008-05-20
;Av Benjamin Ingberg och Patrik Johansson
;
;Animation för när bomber exploder

(load "animation.scm")

(define explosion-animation%
  (class animation%
    (init x y l r u d board)
    (super-new [x x][y y][w 0][h 0][board board][sprites '()])
    
    (define _x x)
    (define _y y)
    (define _l l)
    (define _r r)
    (define _u u)
    (define _d d)
    (define _counter 25)
    (define _board board)
    (define _gradient (list (cons *black-pen* *black-brush*)
                            (cons *red-pen* *red-brush*)
                            (cons *orange-pen* *orange-brush*)
                            (cons *yellow-pen* *yellow-brush*)
                            (cons *white-pen* *white-brush*)))
    
    (define/override (draw)
      (cond ((> _counter 0) (draw-rectangle (- _x _l (- 24))
                                            _y
                                            (+ _l _r)
                                            48
                                            (car (car _gradient))
                                            (cdr (car _gradient)))
                            (draw-rectangle _x
                                            (- _y _u (- 24))
                                            48
                                            (+ _u _d)
                                            (car (car _gradient))
                                            (cdr (car _gradient)))
                            (set! _counter (- _counter 1)))
            ((not (null? (cdr _gradient))) (set! _gradient (cdr _gradient))
                                           (set! _counter 25))
            (else (send _board kill this))))))